-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Add helpers to send Events
from World
#5355
Conversation
World
Events
from World
|
Previously attempted in #3839. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mixed feelings about using the noun-verb grammar, but I wouldn't block that.
I would have suggested you to link to EventWriter
examples, but there are none. 😐
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
2a57b6a
to
e4b489c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add the send_batch
method to have the same features that the EventWriter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to write “Event” in monospace since we're linking to the trait itself and we're passing a type that implements it as an argument.
I'm OK for now to link to the trait instead of the module in the docs, since there is practically no documentation at the module level. This can be changed later with an event docs overhaul.
I prefer that the suggestion made in this comment should be applied before merging.
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
Added |
bors r+ |
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
Pull request successfully merged into main. Build succeeded: |
Events
from World
Events
from World
missed to propose a rename before this was merged: #5383 |
after #5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective - With access to `World`, it's not obvious how to send an event. - This is especially useful if you are writing a `Command` that needs to send an `Event`. - `Events` are a first-class construct in bevy, even though they are just `Resources` under the hood. Their methods should be discoverable. ## Solution - Provide a simple helpers to send events through `Res<Events<T>>`. --- ## Changelog > `send_event`, `send_default_event`, and `send_event_batch` methods added to `World`.
…5383) after bevyengine#5355, three methods were added on world: * `send_event` * `send_event_batch` * `send_default_event` rename `send_default_event` to `send_event_default` for better discoverability
# Objective Use the `World::send_event` method added in #5355 to simplify a doc example for `EventWriter`.
Objective
World
, it's not obvious how to send an event.Command
that needs to send anEvent
.Events
are a first-class construct in bevy, even though they are justResources
under the hood. Their methods should be discoverable.Solution
Res<Events<T>>
.Changelog